package com.lyr;

import com.lyr.service.RedisService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @author liyiruo
 * @Description
 * @Date 2024/8/15 下午3:55
 */
@SpringBootApplication
public class RedisDBApp {
    public static void main(String[] args) {
        SpringApplication.run(RedisDBApp.class, args);
    }

    @Bean
    public CommandLineRunner demo(RedisService redisService) {
        return (args) -> {
            // 保存数据到 Redis
            redisService.saveValue("myKey", "Hello, Redis!");
            // 获取数据从 Redis
            String value = (String) redisService.getValue("myKey");
            System.out.println("Value from Redis: " + value);
        };
    }
}
